<?php

/**
 * This is the model class for table "user_profile".
 *
 * The followings are the available columns in table 'user_profile':
 * @property integer $id
 * @property integer $user_id
 * @property string $full_name
 * @property string $address
 * @property string $avatar
 * @property string $bio
 * @property string $website
 * @property string $yahoo_id
 * @property string $phone
 * @property integer $create_time
 * @property integer $update_time
 */
class UserProfileBase extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return UserProfile the static model class
	 */
	public static function model($className='UserProfile')
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'user_profile';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('user_id, create_time, update_time', 'numerical', 'integerOnly'=>true),
			array('full_name, address, website', 'length', 'max'=>100),
			array('avatar', 'length', 'max'=>200),
			array('bio', 'length', 'max'=>255),
			array('yahoo_id', 'length', 'max'=>50),
			array('phone', 'length', 'max'=>15),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, user_id, full_name, address, avatar, bio, website, yahoo_id, phone, create_time, update_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'user_id' => 'User',
			'full_name' => 'Full Name',
			'address' => 'Address',
			'avatar' => 'Avatar',
			'bio' => 'Bio',
			'website' => 'Website',
			'yahoo_id' => 'Yahoo',
			'phone' => 'Phone',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('full_name',$this->full_name,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('avatar',$this->avatar,true);
		$criteria->compare('bio',$this->bio,true);
		$criteria->compare('website',$this->website,true);
		$criteria->compare('yahoo_id',$this->yahoo_id,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('create_time',$this->create_time);
		$criteria->compare('update_time',$this->update_time);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}